﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_GetDocumentFlowID]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_GetDocumentFlowID];
GO
CREATE PROCEDURE [dbo].[sproc_GetDocumentFlowID]
    @DocID int
AS
DECLARE @FlowID INT

IF EXISTS(SELECT 1 FROM uds_flow_document WHERE doc_id = @DocID)
BEGIN
    SELECT @FlowID = Flow_ID 
        FROM 
            uds_flow_document
        WHERE doc_id = @DocID
    RETURN @FlowID
END
ELSE
    RETURN  -1